package naga.x.platform2.channel.egret.support;

import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;

import naga.x.platform2.utils.CommonUtils;

/**
 * 白鹭、游琥公用API
 * @see <a href="http://open.egret.com/Wiki">白鹭wiki</a>
 * @see <a href="http://developers.yooh5.com/Wiki">游琥平台</a>
 * @author yang.li
 *
 */
public class EgretApi {
	
	public static final int CODE_SUCC = 200;
	public static final int CODE_ERROR = 500;

	public static String makeSign(Map<String, String> map, String appKey) {
		Map<String, String> tree = map instanceof TreeMap ? map : new TreeMap<String, String>(map);
		StringBuilder buf = new StringBuilder(128);
		for (Entry<String, String> entry : tree.entrySet()) {
			String key = entry.getKey();
			if (!"sign".equals(key)) {
				buf.append(entry.getKey()).append('=').append(entry.getValue());
			}
		}
		buf.append(appKey);
		return CommonUtils.md5(buf.toString());
	}
	
}
